<?php

/*
Plugin Name: Sclbkmrks
Plugin URI: http://www.sclbkmrks.eu
Description: Plugin fuer die Anzeige des Social Bookmarks Utility in der Sidebar
Author: Dennis Ploetner
Version: 0.1
License: GPL
Author URI: http://www.ploetner.it
Update Server: http://www.sclbkmrks.eu
*/

function scope_inlucde ($file) {
    if (is_file ($file)) {
        include ($file);
        return (get_defined_vars ());
    }
    return (FALSE);
}

function sclbkmrks($url, $title, $tags = '') {
    require_once(dirname (__FILE__) . '/sozialBookmarks.class.php');
    $sb = new sozialBookmarks($url, $title, $tags);
    $sb->setVar('images', $url . '/wp-content/plugins/sclbkmrks/sb');
    $config = scope_inlucde(dirname (__FILE__) . '/plugin_config.php');
    extract($config);
    $sb->setVar('target', $target);
    $sb->setVar('width', $width);
    $sb->setVar('height', $height);
    $sb->setVar('nofollow', $nofollow);
    $sb->setVar('xhtml', $xhtml);
    $sb->setCode($sb_codes);
    return
        "<div id=\"sclbkmrks\">\n" .
        $sb->getCode() .
        "<p>Powered by <a href=\"http://www.sclbkmrks.eu\" title=\"Social Bookmarks Utility\">Sclbkmrks</p>\n" .
        "</div>\n";
}

function SB_Init_Widget() {
    if (!function_exists('register_sidebar_widget')) return;
    function widget_SCLBKMRKS_EU($args) {
        if (is_home()) {
            extract($args);
            echo $before_widget;
            echo sclbkmrks(get_bloginfo('siteurl'), get_bloginfo());
            echo $after_widget;
        }
    }
    register_sidebar_widget('Sclbkmrks', 'widget_SCLBKMRKS_EU');
}

function SB_Write_CSS() {
    echo
        "\t<style type=\"text/css\" media=\"screen\">\n" .
        "\t\t@import url( " . get_bloginfo('siteurl') . "/wp-content/plugins/sclbkmrks/plugin.css );\n" .
        "\t</style>\n";
}

add_action('plugins_loaded', 'SB_Init_Widget');
add_action('wp_head', 'SB_Write_CSS'); 

?>
